# *_*coding:utf-8 *_*
from abc import abstractmethod

import requests

from py3utils.common_util import catch


class Base(object):
    def __init__(self, headers=None, proxies=None, timeout=120):
        self.proxies = proxies
        self.headers = headers
        self.timeout = timeout

    @catch(raise_error=False, counter=20)
    def _get(self, uri):
        response = requests.get(uri, headers=self.headers, proxies=self.proxies, verify=False, timeout=self.timeout)
        return response

    @abstractmethod
    def add(self, url, filepath, callback, *args, **kwargs):
        pass
